package com.zheng.common.util;

import java.util.Date;

/**
 * 时长卡计时工具
 * Created by Administrator on 2019/04/22.
 */
public class TimeCardUtil {
    /**
     * 时长卡类型常量
     */
    public static final int VALUATION_TYPE_YEAR    = 1;//年卡
    public static final int VALUATION_TYPE_HALF_YEAE     = 2;//半年卡
    public static final int VALUATION_TYPE_QUARTER    = 3;//季度卡
    public static final int VALUATION_TYPE_MONTH     = 4;//月卡
    public static final int VALUATION_TYPE_WEEK     = 5;//周卡
    public static final int VALUATION_TYPE_DATE     = 6;//日卡

    /**
     * 计算指定时长卡类型的到期时间
     * @param date
     * @param type
     * @param num
     * @return
     */
    public static final Date getTimecardEndTime(Date date, int type){
        Date newDate = null;
        switch (type){
            case VALUATION_TYPE_YEAR:{
                return DateUtil.addYears(date,1);
            }
            case VALUATION_TYPE_HALF_YEAE:{
                return DateUtil.addMonths(date,6);
            }
            case VALUATION_TYPE_QUARTER:{
                return DateUtil.addMonths(date,3);
            }
            case VALUATION_TYPE_MONTH:{
                return DateUtil.addMonths(date,1);
            }
            case VALUATION_TYPE_WEEK:{
                return DateUtil.adddays(date,7);
            }
            case VALUATION_TYPE_DATE:{
                return DateUtil.adddays(date,1);
            }
            default:
                return date;
        }
    }


    public static void main(String[] args ){
        System.out.println(DateUtil.date2Str(getTimecardEndTime(DateUtil.getDate(),1)));
        System.out.println(DateUtil.date2Str(getTimecardEndTime(DateUtil.getDate(),2)));
        System.out.println(DateUtil.date2Str(getTimecardEndTime(DateUtil.getDate(),3)));
        System.out.println(DateUtil.date2Str(getTimecardEndTime(DateUtil.getDate(),4)));
        System.out.println(DateUtil.date2Str(getTimecardEndTime(DateUtil.getDate(),5)));
        System.out.println(DateUtil.date2Str(getTimecardEndTime(DateUtil.getDate(),6)));
    }
}
